package com.xuef.ibatis.transaction;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * Created by xuefengDong: moveb
 * On 2019/4/26- 20:02
 * Wraps a database connection.
 * Handles the connection lifecycle that comprises:
 *      its creation, preparation, commit/rollback and close.
 */
public interface Transaction {
    /**
     * Retrieve inner database connection.
     * @return DataBase connection
     * @throws SQLException
     */
    Connection getConnection() throws SQLException;

    /**
     * Commit inner database connection.
     * @throws SQLException
     */
    void commit() throws SQLException;

    /**
     * Rollback inner database connection.
     * @throws SQLException
     */
    void rollback() throws SQLException;

    /**
     * Close inner database connection.
     * @throws SQLException
     */
    void close() throws SQLException;
}
